#include "HerzeleidPrecompiled.hxx"
#include "HerzeleidShaderCore.hxx"
using namespace HerzeleidRendererShadingNamespaceImpl;

HERZELEID_FORCEINLINING HERZELEID_NOALIAS Void HerzeleidRendererShadingNamespaceImpl::BindStageVSDeferred( 
	_In_ NativeDeferredContext3PtrConst pContext, 
	_In_ NativeVertexShaderPtrConst pNativeShader, 
	_In_ PipelineShaderBaseConstPtrConst pContent, 
	_In_opt_ UInt32 uSwapSlot 
	)
{
	pContext->VSSetConstantBuffers( 0u,  HERZELEID_CBUFFER_NUM_SLOTS, pContent->SetArray[uSwapSlot].ConstantBufferArray);
	pContext->VSSetShaderResources( 0u,  HERZELEID_SRV_NUM_SLOTS, pContent->SetArray[uSwapSlot].ShaderResourceViewArray );
	pContext->VSSetSamplers( 0u,  HERZELEID_SAMPLER_NUM_SLOTS, pContent->SetArray[uSwapSlot].SamplerStateArray );
	pContext->VSSetShader( pNativeShader, nullptr, 0u );
}

HERZELEID_FORCEINLINING HERZELEID_NOALIAS Void HerzeleidRendererShadingNamespaceImpl::BindStageHSDeferred( 
	_In_ NativeDeferredContext3PtrConst pContext, 
	_In_ NativeHullShaderPtrConst pNativeShader, 
	_In_ PipelineShaderBaseConstPtrConst pContent, 
	_In_opt_ UInt32 uSwapSlot 
	)
{
	pContext->HSSetConstantBuffers( 0u,  HERZELEID_CBUFFER_NUM_SLOTS, pContent->SetArray[uSwapSlot].ConstantBufferArray);
	pContext->HSSetShaderResources( 0u,  HERZELEID_SRV_NUM_SLOTS, pContent->SetArray[uSwapSlot].ShaderResourceViewArray );
	pContext->HSSetSamplers( 0u,  HERZELEID_SAMPLER_NUM_SLOTS, pContent->SetArray[uSwapSlot].SamplerStateArray );
	pContext->HSSetShader( pNativeShader, nullptr, 0u );
}

HERZELEID_FORCEINLINING HERZELEID_NOALIAS Void HerzeleidRendererShadingNamespaceImpl::BindStageDSDeferred( 
	_In_ NativeDeferredContext3PtrConst pContext, 
	_In_ NativeDomainShaderPtrConst pNativeShader, 
	_In_ PipelineShaderBaseConstPtrConst pContent, 
	_In_opt_ UInt32 uSwapSlot 
	)
{
	pContext->DSSetConstantBuffers( 0u,  HERZELEID_CBUFFER_NUM_SLOTS, pContent->SetArray[uSwapSlot].ConstantBufferArray);
	pContext->DSSetShaderResources( 0u,  HERZELEID_SRV_NUM_SLOTS, pContent->SetArray[uSwapSlot].ShaderResourceViewArray );
	pContext->DSSetSamplers( 0u,  HERZELEID_SAMPLER_NUM_SLOTS, pContent->SetArray[uSwapSlot].SamplerStateArray );
	pContext->DSSetShader( pNativeShader, nullptr, 0u );
}

HERZELEID_FORCEINLINING HERZELEID_NOALIAS Void HerzeleidRendererShadingNamespaceImpl::BindStageGSDeferred( 
	_In_ NativeDeferredContext3PtrConst pContext, 
	_In_ NativeGeometryShaderPtrConst pNativeShader, 
	_In_ PipelineShaderBaseConstPtrConst pContent, 
	_In_opt_ UInt32 uSwapSlot 
	)
{
	pContext->GSSetConstantBuffers( 0u,  HERZELEID_CBUFFER_NUM_SLOTS, pContent->SetArray[uSwapSlot].ConstantBufferArray);
	pContext->GSSetShaderResources( 0u,  HERZELEID_SRV_NUM_SLOTS, pContent->SetArray[uSwapSlot].ShaderResourceViewArray );
	pContext->GSSetSamplers( 0u,  HERZELEID_SAMPLER_NUM_SLOTS, pContent->SetArray[uSwapSlot].SamplerStateArray );
	pContext->GSSetShader( pNativeShader, nullptr, 0u );
}

HERZELEID_FORCEINLINING HERZELEID_NOALIAS Void HerzeleidRendererShadingNamespaceImpl::BindStagePSDeferred( 
	_In_ NativeDeferredContext3PtrConst pContext, 
	_In_ NativePixelShaderPtrConst pNativeShader, 
	_In_ PipelineShaderBaseConstPtrConst pContent, 
	_In_opt_ UInt32 uSwapSlot 
	)
{
	pContext->PSSetConstantBuffers( 0u,  HERZELEID_CBUFFER_NUM_SLOTS, pContent->SetArray[uSwapSlot].ConstantBufferArray);
	pContext->PSSetShaderResources( 0u,  HERZELEID_SRV_NUM_SLOTS, pContent->SetArray[uSwapSlot].ShaderResourceViewArray );
	pContext->PSSetSamplers( 0u,  HERZELEID_SAMPLER_NUM_SLOTS, pContent->SetArray[uSwapSlot].SamplerStateArray );
	pContext->PSSetShader( pNativeShader, nullptr, 0u );
}

HERZELEID_FORCEINLINING HERZELEID_NOALIAS Void HerzeleidRendererShadingNamespaceImpl::BindStageCSDeferred( 
	_In_ NativeDeferredContext3PtrConst pContext, 
	_In_ NativeComputeShaderPtrConst pNativeShader,
	_In_ ComputeShaderBaseConstPtrConst pContent, 
	_In_opt_ UInt32 uSwapSlot 
	)
{
	pContext->CSSetUnorderedAccessViews( 0u, HERZELEID_SRV_NUM_SLOTS, pContent->SetArray[uSwapSlot].UnorderedAccessViewArray, pContent->SetArray[uSwapSlot].UnorderedAccessViewInitialCountArray );
	pContext->CSSetConstantBuffers( 0u,  HERZELEID_CBUFFER_NUM_SLOTS, pContent->SetArray[uSwapSlot].ConstantBufferArray);
	pContext->CSSetShaderResources( 0u,  HERZELEID_SRV_NUM_SLOTS, pContent->SetArray[uSwapSlot].ShaderResourceViewArray );
	pContext->CSSetSamplers( 0u,  HERZELEID_SAMPLER_NUM_SLOTS, pContent->SetArray[uSwapSlot].SamplerStateArray );
	pContext->CSSetShader( pNativeShader, nullptr, 0u );
}

HERZELEID_FORCEINLINING HERZELEID_NOALIAS Void HerzeleidRendererShadingNamespaceImpl::UnbindStageVSDeferred( 
	_In_ NativeDeferredContext3PtrConst pContext 
	)
{
	const static PipelineShaderSwapSet NullContent;
	pContext->VSSetConstantBuffers( 0u, HERZELEID_CBUFFER_NUM_SLOTS, NullContent.ConstantBufferArray );
	pContext->VSSetShaderResources( 0u, HERZELEID_SRV_NUM_SLOTS, NullContent.ShaderResourceViewArray );
	pContext->VSSetSamplers( 0u, HERZELEID_SAMPLER_NUM_SLOTS, NullContent.SamplerStateArray );
	pContext->VSSetShader( nullptr, nullptr, 0u );
}

HERZELEID_FORCEINLINING HERZELEID_NOALIAS Void HerzeleidRendererShadingNamespaceImpl::UnbindStageHSDeferred( 
	_In_ NativeDeferredContext3PtrConst pContext 
	)
{
	const static PipelineShaderSwapSet NullContent;
	pContext->HSSetConstantBuffers( 0u, HERZELEID_CBUFFER_NUM_SLOTS, NullContent.ConstantBufferArray );
	pContext->HSSetShaderResources( 0u, HERZELEID_SRV_NUM_SLOTS, NullContent.ShaderResourceViewArray );
	pContext->HSSetSamplers( 0u, HERZELEID_SAMPLER_NUM_SLOTS, NullContent.SamplerStateArray );
	pContext->HSSetShader( nullptr, nullptr, 0u );
}

HERZELEID_FORCEINLINING HERZELEID_NOALIAS Void HerzeleidRendererShadingNamespaceImpl::UnbindStageDSDeferred( 
	_In_ NativeDeferredContext3PtrConst pContext 
	)
{
	const static PipelineShaderSwapSet NullContent;
	pContext->DSSetConstantBuffers( 0u, HERZELEID_CBUFFER_NUM_SLOTS, NullContent.ConstantBufferArray );
	pContext->DSSetShaderResources( 0u, HERZELEID_SRV_NUM_SLOTS, NullContent.ShaderResourceViewArray );
	pContext->DSSetSamplers( 0u, HERZELEID_SAMPLER_NUM_SLOTS, NullContent.SamplerStateArray );
	pContext->DSSetShader( nullptr, nullptr, 0u );
}

HERZELEID_FORCEINLINING HERZELEID_NOALIAS Void HerzeleidRendererShadingNamespaceImpl::UnbindStageGSDeferred(
	_In_ NativeDeferredContext3PtrConst pContext 
	)
{
	const static PipelineShaderSwapSet NullContent;
	pContext->GSSetConstantBuffers( 0u, HERZELEID_CBUFFER_NUM_SLOTS, NullContent.ConstantBufferArray );
	pContext->GSSetShaderResources( 0u, HERZELEID_SRV_NUM_SLOTS, NullContent.ShaderResourceViewArray );
	pContext->GSSetSamplers( 0u, HERZELEID_SAMPLER_NUM_SLOTS, NullContent.SamplerStateArray );
	pContext->GSSetShader( nullptr, nullptr, 0u );
}

HERZELEID_FORCEINLINING HERZELEID_NOALIAS Void HerzeleidRendererShadingNamespaceImpl::UnbindStagePSDeferred( 
	_In_ NativeDeferredContext3PtrConst pContext 
	)
{
	const static PipelineShaderSwapSet NullContent;
	pContext->PSSetConstantBuffers( 0u, HERZELEID_CBUFFER_NUM_SLOTS, NullContent.ConstantBufferArray );
	pContext->PSSetShaderResources( 0u, HERZELEID_SRV_NUM_SLOTS, NullContent.ShaderResourceViewArray );
	pContext->PSSetSamplers( 0u, HERZELEID_SAMPLER_NUM_SLOTS, NullContent.SamplerStateArray );
	pContext->PSSetShader( nullptr, nullptr, 0u );
}

HERZELEID_FORCEINLINING HERZELEID_NOALIAS Void HerzeleidRendererShadingNamespaceImpl::UnbindStageCSDeferred( 
	_In_ NativeDeferredContext3PtrConst pContext 
	)
{
	const static ComputeShaderSwapSet NullContent;
	pContext->CSSetUnorderedAccessViews( 0u, HERZELEID_CBUFFER_NUM_SLOTS, NullContent.UnorderedAccessViewArray, NullContent.UnorderedAccessViewInitialCountArray );
	pContext->CSSetConstantBuffers( 0u, HERZELEID_CBUFFER_NUM_SLOTS, NullContent.ConstantBufferArray );
	pContext->CSSetShaderResources( 0u, HERZELEID_SRV_NUM_SLOTS, NullContent.ShaderResourceViewArray );
	pContext->CSSetSamplers( 0u, HERZELEID_SAMPLER_NUM_SLOTS, NullContent.SamplerStateArray );
	pContext->CSSetShader( nullptr, nullptr, 0u );
}

ShaderBase::ShaderBase() : 
	eSlot(ShaderSlot::Undefined),
	Bytecode()
{
}

PipelineShaderBase::PipelineShaderBase() : 
	SetArray()
{
}

ComputeShaderBase::ComputeShaderBase() : 
	SetArray()
{
}

CoreVertexShader::CoreVertexShader() : 
	PipelineShader()
{
	eSlot = ShaderSlot::VertexShader;
}

CoreHullShader::CoreHullShader() : 
	PipelineShader()
{
	eSlot = ShaderSlot::HullShader;
}

CoreDomainShader::CoreDomainShader() : 
	PipelineShader()
{
	eSlot = ShaderSlot::DomainShader;
}

CoreGeometryShader::CoreGeometryShader() : 
	PipelineShader()
{
	eSlot = ShaderSlot::GeometryShader;
}

CorePixelShader::CorePixelShader() : 
	PipelineShader()
{
	eSlot = ShaderSlot::PixelShader;
}

CoreComputeShader::CoreComputeShader() :  
	ComputeShaderBase(), 
	NativeShader()
{
	eSlot = ShaderSlot::ComputeShader;
}















